package com.sc.VenusQueryBeta.model.search;

import com.hengjun.kingstar.sdk.base.BaseModel;
import com.hengjun.kingstar.sdk.helper.RetrofitCreateHelper;
import com.hengjun.kingstar.sdk.helper.RxHelper;
import com.sc.VenusQueryBeta.api.Host;
import com.sc.VenusQueryBeta.api.home.HomeApi;
import com.sc.VenusQueryBeta.contract.search.SearchContract;
import com.sc.VenusQueryBeta.model.bean.home.KeyWordListBean;
import com.sc.VenusQueryBeta.model.bean.home.SearchListBean;

import io.reactivex.Observable;

/**
 * 設置model 继承Basemodel 并且实现契约累的model方法
 */

public class SearchModel extends BaseModel implements SearchContract.ISearchModel {
    /**
     * 实例化对象
     * @return
     */
    public static SearchModel newInstance(){
        return new SearchModel();
    }

    @Override
    public Observable<KeyWordListBean> getKeyWordList() {
        return RetrofitCreateHelper.createApi(HomeApi.class, Host.Host).getKeyWordList().compose(RxHelper.<KeyWordListBean>rxSchedulerHelper());
    }

    @Override
    public Observable<SearchListBean> search(String keyword) {
        return RetrofitCreateHelper.createApi(HomeApi.class, Host.Host).search(keyword).compose(RxHelper.<SearchListBean>rxSchedulerHelper());
    }
}
